package com.own.business.message.center.entity.vo;

import com.own.business.message.center.entity.po.MessageCenterContent;
import com.own.component.common.base.entity.vo.BaseVo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * MessageCenterContentVo
 *
 * @author chenxueli
 * @date 2023-11-13 14:39:27
 */
@Schema(title = "消息中心内容" + ConstantBeanSuffix.VO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class MessageCenterContentVo extends BaseVo<MessageCenterContent> implements Serializable {

    @Schema(title = "接收消息的用户id")
    private Long receiveId;

    @Schema(title = "消息内容（展示的一小部分）")
    private String content;

    @Schema(title = "消息详情内容（json格式字符串）")
    private String detailContent;

    @Schema(title = "分组key")
    private String groupKey;

    @Schema(title = "消息key")
    private String messageKey;

    @Schema(title = "业务id")
    private Long businessId;

    @Schema(title = "是否已读（0=未读 1=已读）")
    private Integer isRead;

    @Schema(title = "已读时间")
    private LocalDateTime readTime;

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public MessageCenterContentVo(@NonNull MessageCenterContent entity) {
        super(entity);
        this.receiveId = entity.getFkReceiveId();
        this.content = entity.getContent();
        this.detailContent = entity.getDetailContent();
        this.groupKey = entity.getGroupKey();
        this.messageKey = entity.getMessageKey();
        this.businessId = entity.getFkBusinessId();
        this.isRead = entity.getIsRead();
        this.readTime = entity.getReadTime();
    }

    /**
     * 转po对象
     *
     * @param entity 原对象
     * @return po对象
     */
    @Override
    public MessageCenterContent toPo(MessageCenterContent entity) {
        if (entity == null) {
            entity = new MessageCenterContent();
        }
        entity.setFkReceiveId(this.receiveId);
        entity.setContent(this.content);
        entity.setDetailContent(this.detailContent);
        entity.setGroupKey(this.groupKey);
        entity.setMessageKey(this.messageKey);
        entity.setFkBusinessId(this.businessId);
        entity.setIsRead(this.isRead);
        entity.setReadTime(this.readTime);
        return super.toPo(entity);
    }

}
